import {observable, action,} from 'mobx';
import { ListViewPage } from 'weaver-mobile-page';
import * as Api from '../../api/roomPlan';
import { Browser } from 'weaver-mobile-page';

export default class roomPlanRoom {
    @observable list = new ListViewPage.Store({route: '/roomPlan'});
    @observable roomMeetTabs = []; // roomMeetTabs中的会议室和roomMeetID中的id一一对应
    @observable roomMeetID = [];
    @observable roomid = '22';
    @observable color ={
      agreementColor: '',
      conflictedColor:'',
      usedColor: ''
    };
    @observable startHour = '';
    @observable endHour = '';
    @observable comsWeaTableStore = {};
    @observable roomMeeting = [];
    @observable useMap = {}; // key为roomid,value为使用信息
    @observable duration = 0; // 最小间隔时间
    
    @observable browser1 = new Browser.Store({route: '/calendar/detail/index/roomPlan'})

    @action 
    setState = (params = {}) => {
      Object.keys(params).forEach(key => {
        this[key] = params[key];
      });
    }

    @action 
    initRoomBrowser = (params) => {
      this.browser1 = new Browser.Store({route: `${params}`, id: 'roomBrowser'})
    }

    initData() {
      this.getRoomReportBaseData();
      // this.getRoomReportList({roomid: this.roomid});
    }
    
    getRoomReportBaseData = () => {
      Api.getRoomReportBaseData().then((res) => {
        this.color = {...this.color, agreementColor:res.agreementColor, conflictedColor:res.conflictedColor, usedColor:res.usedColor};
        this.startHour = res.timestart;
        this.endHour = res.timeend;
      });
    }

    getRoomMeetingList = (params) => {
      // Api.getRoomMeetingList(params).then(data => {
      //   console.log('data',data.datas)
      //   this.list = data.datas;
      // });
      this.list.clearData();
      this.list = new ListViewPage.Store({route: '/roomPlan'});
      let options = {
        method: 'POST',
        url: '/api/meeting/field/getMeetingReportDetailForMobile',
        params: {...params, ismobile: 1},
        type: 'json'
      };
      this.list.getDataCustom(options)
    }

    // 查询会议列表
    getRoomReportList = (params, callback) => {
      Api.getRoomReportList(params).then(data => {
        const dataKey = data.sessionkey;
        this.list.clearData();
        if(dataKey) {
          this.dataKey = dataKey;
        }
        this.list.getData({dataKey});
      });
    }
}